#!/usr/bin/env python

from fusion.daemon import default_welcome
from fusion.discovery.discover import discover

def probe_iid(iid):
    result = discover(iid, maxvals=100)
    if result is None:
        print '(Discovery returned None.)'
    else:
        for item in result:
            probe_node_id(item['id'])

def probe_node_id(node_id):
    print '%s:' % node_id
    result = discover(node_id, maxvals=100)
    if result is None:
        print '  (None)'
    else:
        for item in result:
            print '  %s' % item['addresses']

if __name__ == '__main__':
    import sys

    if len(sys.argv) > 1:
        iid = sys.argv[1]
    else:
        iid = default_welcome

    probe_iid(iid)
